package com.gu.qqdemo.frg;

import android.graphics.Color;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gu.qqdemo.R;
import com.gu.qqdemo.adapter.ViewPageAdapter;
import com.gu.qqdemo.utils.app.BaseFragment;

public class MainFragment2 extends BaseFragment {

    private ViewPager pager_vp;
    private TabLayout table;
    private BaseFragment[] bfgs;
    private String[] tables;


    @Override
    protected int getLayoutId() {
        return 0;
    }

    @Override
    protected View initView(LayoutInflater inflater, ViewGroup container) {
        View view = inflater.inflate(R.layout.act_viewpager, container, false);
        pager_vp = view.findViewById(R.id.pager_vp);
        table = view.findViewById(R.id.table);
        return view;
    }

    @Override
    protected void initData() {
        table.setSelectedTabIndicatorColor(Color.BLACK);
        table.setSelectedTabIndicatorHeight(8);
        table.setTabMode(TabLayout.GRAVITY_CENTER);
        tables = new String[]{"好友", "群聊", "设备", "通讯录", "公众号"};
        bfgs = new BaseFragment[]{new ViewPagerFriendFragment(), new ViewPagerGroupFragment(),
                new ViewPagerFacilityFragment(), new ViewPagerBookFragment(), new ViewPagerVipcnFragment()};
        ViewPageAdapter viewPageAdapter = new ViewPageAdapter(getChildFragmentManager(), bfgs, tables);
        pager_vp.setAdapter(viewPageAdapter);
        pager_vp.setOffscreenPageLimit(bfgs.length - 1);
        table.setupWithViewPager(pager_vp,true);
    }

    @Override
    protected void initListener() {
    }
}
